package com.secf.service.port.hpy.hys.test;

import java.util.Arrays;

/**
 * @Author ms
 * @Date 2024-08-08 15:54
 */
public class ArrayTest1 {
    public static void main(String[] args) {
        // 测试数组的声明与初始化
        int[] numbers = {4, 2, 7, 1, 9};
        System.out.println("原始数组: " + Arrays.toString(numbers));

        // 测试数组的排序
        Arrays.sort(numbers);
        System.out.println("排序后的数组: " + Arrays.toString(numbers));

        // 测试数组的二分查找
        int index = Arrays.binarySearch(numbers, 7);
        System.out.println("数字7的索引: " + index);

        // 测试数组的复制
        int[] copiedArray = Arrays.copyOf(numbers, 10);
        System.out.println("复制后的数组（新长度为10）: " + Arrays.toString(copiedArray));
    }
}
